dates=(
20230120
20230121
20230122
20230123
20230124
20230125
20230126
20230127
20230128
20230129
20230130
20230131
)

machines=(
coin-seoul-fill-nano-01
strategy-28.ap-northeast-1c.huobi
)

exchanges=(
"Gateio"
"Huobi"
"Mexc"
)

# fill
rm -f fill_list.txt
for d in ${dates[@]}
do
  for m in ${machines[@]}
  do
    ls /remote/iosg/strat-1/buckets/analysis.derived.coin/og_analysis/etl/strat_proto_log/$m/$d/*order_fill_filter.json | grep -v prex >> fill_list.txt
  done
done

rm -f selected_fills.json
cat fill_list.txt | xargs -n1 jq 'select(.exchange + "___" + .owner | test("(.*Huobi.*prestoinvt23.*)|(.*Mexc.*prestoinvt07.*)|(.*Gateio.*xunke02.*)"))' >> selected_fills.json

for e in ${exchanges[@]}
do
  jq -s '[.[] | select(.exchange=="'$e'")]' selected_fills.json > ${e}_selected_fills.json
done

# balance
rm -f balance_list.txt
for d in ${dates[@]}
do
  for m in ${machines[@]}
  do
    ls /remote/iosg/strat-1/buckets/analysis.derived.coin/og_analysis/etl/strat_proto_log/$m/$d/*.balance_filter.json | grep -v prex >> balance_list.txt
  done
done

rm -f selected_balance.json
cat balance_list.txt | xargs -n1 jq 'select(.exchange + "___" + .owner | test("(.*Huobi.*prestoinvt23.*)|(.*Mexc.*prestoinvt07.*)|(.*Gateio.*xunke02.*)"))' >> selected_balance.json

for e in ${exchanges[@]}
do
  jq -s '[.[] | select(.exchange=="'$e'")]' selected_balance.json > ${e}_selected_balance.json
done

for e in ${exchanges[@]}
do
  python plot.py ${e}_selected_balance.json ${e}_selected_fills.json
done
